package com.leoren.run.utils;

import com.amap.api.location.CoordinateConverter;
import com.amap.api.location.DPoint;
import com.amap.api.maps.model.LatLng;
import com.leoren.run.log.L;

/**
 * Location的各工具类
 */
public class LocationUtils {

    /**
     * 判断是否是同一点
     * @param nowLocation
     * @param firstLocation
     * @return
     */
    public static boolean IsLocation(LatLng nowLocation, LatLng firstLocation){

        L.e("是否为同一点\n" + nowLocation + firstLocation);
        DPoint nowPoint = new DPoint(nowLocation.latitude, nowLocation.longitude);
        DPoint firstPoint = new DPoint(firstLocation.latitude, nowLocation.longitude);

        float distance = CoordinateConverter.calculateLineDistance(nowPoint, firstPoint);
        if(distance < 10){
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        LatLng latLng1 = new LatLng(37.5237464904785160,111.1333389282226600);
        LatLng latLng2 = new LatLng(37.5236625671386700, 111.1333389282226600);
        System.out.println(IsLocation(latLng1, latLng2));
    }

}
